//
//  PickNum11YDJViewController.m
//  PlayBall
//
//  Created by Jdd‘s macbook on 13-10-9.
//
//

#import "JddPickNum11YDJViewController.h"
#import "JddPickNum11YDJListViewController.h"
#import "JddViewControllerManager.h"
#import "JddCommonFunction.h"
#import "NoticeViewController.h"
#import "FloatLayer.h"
@interface JddPickNum11YDJViewController (){
    NSInteger _floatLayerIndex;
    FloatLayer *_layer;
    NSMutableArray *_playMethodArr;
}

@end

@implementation JddPickNum11YDJViewController
SHARED_VIEW_CONTROLLER_IMPLEMENT(JddPickNum11YDJViewController);
@synthesize label3;
@synthesize label1;
@synthesize label2;
@synthesize image;
@synthesize issueCodeLabel;
@synthesize remainTimeLabel;
@synthesize currentLotteryIssue;
@synthesize playFormLabel;
@synthesize playFormIndexLabel;
@synthesize playFormMoneyLabel;
@synthesize playPickView;
@synthesize countlabel;
@synthesize moneylabel;
int selectType;

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if ([alertView.message isEqualToString:@"您还没有登录，请先登录"]) {
        if (buttonIndex == 0) {
            countlabel.text = @"0";
            moneylabel.text = @"0";
            [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:
             CONTROLLER_LOGIN
                                                                 fromController:self
                                                                     withObject:nil
                                                                    withObject2:nil];
        }
    }
}

- (IBAction)numberButtonClicked:(id)sender{
    UIButton *button = sender;
    [button setSelected:![button isSelected]];
    if (button.tag == 11) {
        if ([button isSelected]) {
            [lotteryNumber addBallNumber:[button.titleLabel.text intValue]];
        }
        else {
            [lotteryNumber removeBallNumber:[button.titleLabel.text intValue]];
        }
    } else if (button.tag == 22) {
        if ([button isSelected]) {
            [lotteryNumber add2BallNumber:[button.titleLabel.text intValue]];
        }
        else {
            [lotteryNumber remove2BallNumber:[button.titleLabel.text intValue]];
        }
    }else if (button.tag == 33) {
        if ([button isSelected]) {
            [lotteryNumber add3BallNumber:[button.titleLabel.text intValue]];
        }
        else {
            [lotteryNumber remove3BallNumber:[button.titleLabel.text intValue]];
        }
    }
    if ([button isSelected]) {
        [JddCommonFunction animationViewWithZoomOutIn:button delaySecond:0];
    }
    [self countMoney];
}

-(void)countMoney{
    NSInteger noteAmount = 0;
    if (selectType==LOTTERY_PLAY_METHOD_11YDJ_GROUP2) {
        if ([lotteryNumber.BallArray count]>1) {
            noteAmount += [JddCommonFunction count11YDJTotalNumber:[lotteryNumber.BallArray count] playmethod:selectType];
        }
        
    }else if (selectType== LOTTERY_PLAY_METHOD_11YDJ_GROUP3){
        if ([lotteryNumber.BallArray count]>2) {
            noteAmount += [JddCommonFunction count11YDJTotalNumber:[lotteryNumber.BallArray count] playmethod:selectType];
        }
        
    }else if (selectType== LOTTERY_PLAY_METHOD_11YDJ_ONLY2){
        for (NSNumber *number in lotteryNumber.BallArray) {
            for (NSNumber *number2 in lotteryNumber.SecondBallArray) {
                if (number2!=number) {
                    noteAmount++;
                }
            }
        }
        
    }else if (selectType== LOTTERY_PLAY_METHOD_11YDJ_ONLY3){
        for (NSNumber *number in lotteryNumber.BallArray) {
            for (NSNumber *number2 in lotteryNumber.SecondBallArray) {
                if (number2!=number) {
                    for (NSNumber *number3 in lotteryNumber.ThirdBallArray) {
                        if (number3!=number2&&number3!=number) {
                            noteAmount++;
                        }
                    }
                }
            }
        }
        
    }else if(selectType<LOTTERY_PLAY_METHOD_11YDJ_ONLY2){
        if ([lotteryNumber.BallArray count]>(selectType-LOTTERY_PLAY_METHOD_11YDJ_ANY1)) {
            noteAmount += [JddCommonFunction count11YDJTotalNumber:[lotteryNumber.BallArray count] playmethod:selectType];
        }
    }
    
    
    countlabel.text = [NSString stringWithFormat:@"%d", noteAmount];
    moneylabel.text = [NSString stringWithFormat:@"%d", noteAmount * 2];
    
}

-(void)selectMatch11YJD:(NSString*)Value{
    if ([Value isEqualToString:@"任选一"]) {
        selectType = LOTTERY_PLAY_METHOD_11YDJ_ANY1;
    } else  if ([Value isEqualToString:@"任选二"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ANY2;
    }else  if ([Value isEqualToString:@"任选三"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ANY3;
    }else  if ([Value isEqualToString:@"任选四"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ANY4;
    }else  if ([Value isEqualToString:@"任选五"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ANY5;
    }else  if ([Value isEqualToString:@"任选六"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ANY6;
    }else  if ([Value isEqualToString:@"任选七"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ANY7;
    }else  if ([Value isEqualToString:@"任选八"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ANY8;
    }else  if ([Value isEqualToString:@"前二直选"]){
        for (UIView *subView in self.view.subviews) {
            if (subView.tag == 22) {
                ((UIButton*)subView).hidden = NO;
            }
        }
        UIButton *button2 = (UIButton*)[self.view viewWithTag:23];
        button2.hidden = NO;
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ONLY2;
        [self hiddenButton2];
    }else  if ([Value isEqualToString:@"前三直选"]){
        for (UIView *subView in self.view.subviews) {
            if (subView.tag == 22) {
                ((UIButton*)subView).hidden = NO;
            }
        }
        UIButton *button2 = (UIButton*)[self.view viewWithTag:23];
        button2.hidden = NO;
        for (UIView *subView in self.view.subviews) {
            if (subView.tag == 33) {
                ((UIButton*)subView).hidden = NO;
            }
        }
        UIButton *button4 = (UIButton*)[self.view viewWithTag:34];
        button4.hidden = NO;
        selectType= LOTTERY_PLAY_METHOD_11YDJ_ONLY3;
    }else  if ([Value isEqualToString:@"前二组选"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_GROUP2;
    }else  if ([Value isEqualToString:@"前三组选"]){
        selectType= LOTTERY_PLAY_METHOD_11YDJ_GROUP3;
    }
    int b = selectType - LOTTERY_PLAY_METHOD_11YDJ_ANY0;
    switch (b % 12) {
        case 1:
            playFormMoneyLabel.text = @"13彩豆";
            playFormIndexLabel.text = @"投注与开奖号码第1位相同，即中奖";
            playFormLabel.text = @"任选一";
            label1.hidden = YES;
            label2.hidden = YES;
            label3.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 2:
            playFormMoneyLabel.text = @"6彩豆";
            playFormIndexLabel.text = @"投注与开奖号码任意2个相同，即中奖";
            playFormLabel.text = @"任选二";
            label1.hidden = YES;
            label2.hidden = YES;
            label3.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 3:
            playFormMoneyLabel.text = @"19彩豆";
            playFormIndexLabel.text = @"投注与开奖号码任意3个相同，即中奖";
            playFormLabel.text = @"任选三";
            label1.hidden = YES;
            label2.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            label3.hidden = YES;
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 4:
            playFormMoneyLabel.text = @"78彩豆";
            playFormIndexLabel.text = @"投注与开奖号码任意4个相同，即中奖";
            playFormLabel.text = @"任选四";
            label1.hidden = YES;
            label2.hidden = YES;
            label3.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 5:
            playFormMoneyLabel.text = @"540彩豆";
            playFormIndexLabel.text = @"投注与开奖号码5个相同，即中奖";
            playFormLabel.text = @"任选五";
            label1.hidden = YES;
            label2.hidden = YES;
            label3.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 6:
            playFormMoneyLabel.text = @"90彩豆";
            playFormIndexLabel.text = @"投注与开奖号码5个相同，即中奖";
            playFormLabel.text = @"任选六";
            label1.hidden = YES;
            label2.hidden = YES;
            label3.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 7:
            playFormMoneyLabel.text = @"26彩豆";
            playFormIndexLabel.text = @"投注与开奖号码5个相同，即中奖";
            playFormLabel.text = @"任选七";
            label1.hidden = YES;
            label2.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            label3.hidden = YES;
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 8:
            playFormMoneyLabel.text = @"9彩豆";
            playFormIndexLabel.text = @"投注与开奖号码5个相同，即中奖";
            playFormLabel.text = @"任选八";
            label1.hidden = YES;
            label2.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            label3.hidden = YES;
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 9:
            playFormMoneyLabel.text = @"130彩豆";
            playFormIndexLabel.text = @"投注与开奖号码前2位顺序一致，即中奖";
            playFormLabel.text = @"前二直选";
            label1.hidden = NO;
            label2.hidden = NO;
            image.image= [UIImage imageNamed:@"jdd_pmbj.png"];
            label3.hidden = YES;
            break;
        case 11:
            playFormMoneyLabel.text = @"65彩豆";
            playFormIndexLabel.text = @"投注与开奖号码前2位相同，即中奖";
            playFormLabel.text = @"前二组选";
            label1.hidden = YES;
            label2.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            label3.hidden = YES;
            [self hiddenButton];
            [self hiddenButton2];
            break;
        case 10:
            playFormMoneyLabel.text = @"1170彩豆";
            playFormIndexLabel.text = @"投注与开奖号码前3位顺序一致，即中奖";
            playFormLabel.text = @"前三直选";
            label1.hidden = NO;
            image.image= [UIImage imageNamed:@"jdd_pmbj.png"];
            label2.hidden = NO;
            label3.hidden = NO;
            break;
        case 0:
            playFormMoneyLabel.text = @"195彩豆";
            playFormIndexLabel.text = @"投注与开奖号码前3位相同，即中奖";
            playFormLabel.text = @"前三组选";
            label1.hidden = YES;
            image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
            label2.hidden = YES;
            label3.hidden = YES;
            [self hiddenButton];
            [self hiddenButton2];
            break;
            
        default:
            break;
    }
    [lotteryNumber clear];
    countlabel.text = @"0";
    moneylabel.text = @"0";
    for (UIView *subView in self.view.subviews) {
        if ([[subView class] isSubclassOfClass:[UIButton class]] ||
            subView.tag == 11||subView.tag == 22 ||subView.tag == 33) {
            [((UIButton*)subView) setSelected:NO];
        }
    }
    [self setRbtnTitle:[NSString stringWithFormat:@"%@-%@",PAGE_11YDJ_PICK_NUMBER,playFormLabel.text]];
}

- (void)changeButtonClicked:(id)sender{
    [self selectPlayMethodButtonClicked];
}

- (IBAction)randomSelect5:(id)sender {
    NSNumber *playmetoh = [NSNumber numberWithInt:selectType];
    [lotteryNumberArray removeAllObjects];
    for (int i = 0; i < 5; ++i) {
        JddS5F11Number *number = [[JddS5F11Number alloc] init];
        [JddCommonFunction generateBallOf11YDJNumber:number type:selectType];
        [lotteryNumberArray addObject:number];
    }
    [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                            fromController:self
                                                                withObject:lotteryNumberArray
                                                               withObject2:playmetoh];
    

}

-(void)hiddenButton{
    for (UIView *subView in self.view.subviews) {
        if (subView.tag == 22) {
            ((UIButton*)subView).hidden = YES;
        }
    }
    for (UIView *subView in self.view.subviews) {
        if (subView.tag == 33) {
            ((UIButton*)subView).hidden = YES;
        }
    }
    UIButton *button2 = (UIButton*)[self.view viewWithTag:23];
    button2.hidden = YES;
    UIButton *button4 = (UIButton*)[self.view viewWithTag:34];
    button4.hidden = YES;
}

-(void)hiddenButton2{
    for (UIView *subView in self.view.subviews) {
        if (subView.tag == 33) {
            ((UIButton*)subView).hidden = YES;
        }
    }
    UIButton *button4 = (UIButton*)[self.view viewWithTag:34];
    button4.hidden = YES;
}


//设置彩种，后进行刷新数据
- (void)setLotteryContent:(NSInteger)tag{
    
    
    _floatLayerIndex = tag;
    [_layer loadFloatLayer:_playMethodArr withIndex:_floatLayerIndex];
    NSString *title = [_playMethodArr objectAtIndex:_floatLayerIndex];
    [self selectMatch11YJD:title];
    
}

-(void)selectPlayMethodButtonClicked{
    if (!_playMethodArr) {
        _playMethodArr = [[NSMutableArray alloc] initWithObjects:@"任选一",@"任选二",@"任选三",@"任选四",@"任选五",@"任选六",@"任选七",@"任选八",@"前二直选",@"前三直选",@"前二组选",@"前三组选", nil];
    }
    //NSArray *playMethod = [[NSArray alloc] initWithObjects:@"任选一",@"任选二",@"任选三",@"任选四",@"任选五",@"任选六",@"任选七",@"任选八",@"前二直选",@"前三直选",@"前二组选",@"前三组选", nil];
    
    if (!_layer) {
        _layer = [[FloatLayer alloc] initWithFloatLayer:FloatLayerTogetherBuy withLayerCallBack:^(NSInteger index) {
            [self setLotteryContent:index];
        }];
    }
    
    [_layer loadFloatLayer:_playMethodArr withIndex:_floatLayerIndex];
    
    /*
    CGRect rect = [[UIScreen mainScreen] bounds];
    rect.origin.x = (rect.size.width - 251) / 2.0;
    rect.origin.y = (rect.size.height - 139) / 2.0;
    rect.size.width = 251.0;
    rect.size.height = 139.0;
    methodPick = [JddComboBoxView getInstanceView];
    [methodPick setFrame:rect];
    methodPick.dataArray = [NSArray arrayWithArray:playMethod];
    methodPick.type = 1;
    methodPick.commitButton.hidden = YES;
    methodPick.commitLabel.hidden = NO;
    methodPick.delegate = self;
    [methodPick show];
     */
}


- (void)RandomSelectNumViewClickedButtonAtIndex:(NSNumber*)buttonIndex multiple:(NSNumber*)multiple{
    NSNumber *playmetoh = [NSNumber numberWithInt:selectType];
    if ([buttonIndex intValue]== 1) {
        [lotteryNumberArray removeAllObjects];
        for (int i = 0; i < [multiple intValue]; ++i) {
            JddS5F11Number *number = [[JddS5F11Number alloc] init];
            [JddCommonFunction generateBallOf11YDJNumber:number type:selectType];
            [lotteryNumberArray addObject:number];
        }
        
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                             fromController:self
                                                                 withObject:lotteryNumberArray
                                                                withObject2:playmetoh];
    }
}

-(IBAction)clearSelect:(id)sender{
    [lotteryNumber clear];
    countlabel.text = @"";
    moneylabel.text = @"";
    
    for (UIView *subView in self.view.subviews) {
        if ([[subView class] isSubclassOfClass:[UIButton class]] ||
            subView.tag == 11||subView.tag == 22 ||subView.tag == 33) {
            [((UIButton*)subView) setSelected:NO];
        }
    }
    
}
-(IBAction)sureSelect:(id)sender{
    NSNumber *playmetoh = [NSNumber numberWithInt:selectType];
    if ([[JddPickNum11YDJListViewController sharedInstance].numberListTable numberOfRowsInSection:0]>0) {
        if (selectType<LOTTERY_PLAY_METHOD_11YDJ_ONLY2&&selectType>LOTTERY_PLAY_METHOD_11YDJ_ANY0) {
            if ([lotteryNumber.BallArray count] < (selectType-LOTTERY_PLAY_METHOD_11YDJ_ANY0)&&[lotteryNumber.BallArray count]>0) {
                switch (selectType) {
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY1:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_1];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY2:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_2];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY3:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_3];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY4:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_4];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY5:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_5];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY6:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_6];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY7:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_7];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY8:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_8];
                        break;
                        
                    default:
                        break;
                }
                return;
            } else if ([lotteryNumber.BallArray count]==0){
                [[JddViewControllerManager sharedInstance].navigationController pushViewController:[JddPickNum11YDJListViewController sharedInstance] animated:YES];
            }else {
                [lotteryNumberArray removeAllObjects];
                JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
                [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
                [newNumber.SecondBallArray addObjectsFromArray:lotteryNumber.SecondBallArray];
                [newNumber.ThirdBallArray addObjectsFromArray:lotteryNumber.ThirdBallArray];
                [lotteryNumberArray addObject:newNumber];
                [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                     fromController:self
                                                                         withObject:lotteryNumberArray
                                                                        withObject2:playmetoh];
            }
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_ONLY2) {
            if ([lotteryNumber.BallArray count]>0||[lotteryNumber.SecondBallArray count]>0) {
                if ([lotteryNumber.BallArray count] < 1) {
                    [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_9];
                    return;
                }else {
                    if ([lotteryNumber.SecondBallArray count]<1) {
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_10];
                        return;
                    }else {
                        NSInteger num = 0;
                        for (NSNumber *number in lotteryNumber.BallArray) {
                            for (NSNumber *number2 in lotteryNumber.SecondBallArray) {
                                if (number2!=number) {
                                    num++;
                                }
                            }
                        }
                        if (num == 0) {
                            [JddCommonFunction messageBoxWithMessage:@"请至少选择两个不同号码"];
                            return;
                        }
                    }
                    
                }
                
                [lotteryNumberArray removeAllObjects];
                JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
                [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
                [newNumber.SecondBallArray addObjectsFromArray:lotteryNumber.SecondBallArray];
                [lotteryNumberArray addObject:newNumber];
                [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                     fromController:self
                                                                         withObject:lotteryNumberArray
                                                                        withObject2:playmetoh];
            }else if ([lotteryNumber.SecondBallArray count]==0 &&[lotteryNumber.BallArray count]==0) {
                [[JddViewControllerManager sharedInstance].navigationController pushViewController:[JddPickNum11YDJListViewController sharedInstance] animated:YES];
            }
            
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_ONLY3) {
            if ([lotteryNumber.SecondBallArray count]>0||[lotteryNumber.BallArray count]>0||[lotteryNumber.ThirdBallArray count]>0) {
                if ([lotteryNumber.BallArray count] < 1) {
                    [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_9];
                    return;
                }else {
                    if ([lotteryNumber.SecondBallArray count]<1) {
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_10];
                        return;
                    }else {
                        if ([lotteryNumber.ThirdBallArray count]<1) {
                            [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_11];
                            return;
                        }else {
                            NSInteger num = 0;
                            for (NSNumber *number in lotteryNumber.BallArray) {
                                for (NSNumber *number2 in lotteryNumber.SecondBallArray) {
                                    if (number2!=number) {
                                        for (NSNumber *number3 in lotteryNumber.ThirdBallArray) {
                                            if (number3!=number2&&number3!=number) {
                                                num++;
                                            }
                                        }
                                    }
                                }
                            }
                            if (num == 0) {
                                [JddCommonFunction messageBoxWithMessage:@"请至少选择三个不同号码"];
                                return;
                            }
                        }
                    }
                }
                
                [lotteryNumberArray removeAllObjects];
                JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
                [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
                [newNumber.SecondBallArray addObjectsFromArray:lotteryNumber.SecondBallArray];
                [newNumber.ThirdBallArray addObjectsFromArray:lotteryNumber.ThirdBallArray];
                [lotteryNumberArray addObject:newNumber];
                [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                     fromController:self
                                                                         withObject:lotteryNumberArray
                                                                        withObject2:playmetoh];
            }else if([lotteryNumber.SecondBallArray count]==0&&[lotteryNumber.BallArray count]==0&&[lotteryNumber.ThirdBallArray count]==0) {
                [[JddViewControllerManager sharedInstance].navigationController pushViewController:[JddPickNum11YDJListViewController sharedInstance] animated:YES];
            }
            
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_GROUP2) {
            if ([lotteryNumber.BallArray count] < 2&&[lotteryNumber.BallArray count]>0) {
                [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_2];
                return;
            } else if ([lotteryNumber.BallArray count]==0) {
                [[JddViewControllerManager sharedInstance].navigationController pushViewController:[JddPickNum11YDJListViewController sharedInstance] animated:YES];
            }else {
                [lotteryNumberArray removeAllObjects];
                JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
                [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
                [lotteryNumberArray addObject:newNumber];
                [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                     fromController:self
                                                                         withObject:lotteryNumberArray
                                                                        withObject2:playmetoh];
            }
            
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_GROUP3) {
            if ([lotteryNumber.BallArray count] < 3&&[lotteryNumber.BallArray count]>0) {
                [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_3];
                return;
            } else if ([lotteryNumber.BallArray count]==0) {
                [[JddViewControllerManager sharedInstance].navigationController pushViewController:[JddPickNum11YDJListViewController sharedInstance] animated:YES];
            }else {
                
                [lotteryNumberArray removeAllObjects];
                JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
                [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
                [lotteryNumberArray addObject:newNumber];
                [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                     fromController:self
                                                                         withObject:lotteryNumberArray
                                                                        withObject2:playmetoh];
            }
            
        }
        
        
    }else {
        if (selectType<LOTTERY_PLAY_METHOD_11YDJ_ONLY2&&selectType>LOTTERY_PLAY_METHOD_11YDJ_ANY0) {
            if ([lotteryNumber.BallArray count] < (selectType-LOTTERY_PLAY_METHOD_11YDJ_ANY0)) {
                switch (selectType) {
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY1:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_1];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY2:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_2];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY3:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_3];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY4:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_4];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY5:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_5];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY6:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_6];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY7:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_7];
                        break;
                    case LOTTERY_PLAY_METHOD_11YDJ_ANY8:
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_8];
                        break;
                        
                    default:
                        break;
                }
                return;
            }
            
            [lotteryNumberArray removeAllObjects];
            JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
            [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
            [newNumber.SecondBallArray addObjectsFromArray:lotteryNumber.SecondBallArray];
            [newNumber.ThirdBallArray addObjectsFromArray:lotteryNumber.ThirdBallArray];
            [lotteryNumberArray addObject:newNumber];
            [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                 fromController:self
                                                                     withObject:lotteryNumberArray
                                                                    withObject2:playmetoh];
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_ONLY2) {
            if ([lotteryNumber.BallArray count] < 1) {
                [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_9];
                return;
            }else {
                if ([lotteryNumber.SecondBallArray count]<1) {
                    [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_10];
                    return;
                }else {
                    NSInteger num = 0;
                    for (NSNumber *number in lotteryNumber.BallArray) {
                        for (NSNumber *number2 in lotteryNumber.SecondBallArray) {
                            if (number2!=number) {
                                num++;
                            }
                        }
                    }
                    if (num == 0) {
                        [JddCommonFunction messageBoxWithMessage:@"请至少选择两个不同号码"];
                        return;
                    }
                }
                
            }
            
            [lotteryNumberArray removeAllObjects];
            JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
            [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
            [newNumber.SecondBallArray addObjectsFromArray:lotteryNumber.SecondBallArray];
            [lotteryNumberArray addObject:newNumber];
            [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                 fromController:self
                                                                     withObject:lotteryNumberArray
                                                                    withObject2:playmetoh];
            
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_ONLY3) {
            if ([lotteryNumber.BallArray count] < 1) {
                [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_9];
                return;
            }else {
                if ([lotteryNumber.SecondBallArray count]<1) {
                    [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_10];
                    return;
                }else {
                    if ([lotteryNumber.ThirdBallArray count]<1) {
                        [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_11];
                        return;
                    }else {
                        NSInteger num = 0;
                        for (NSNumber *number in lotteryNumber.BallArray) {
                            for (NSNumber *number2 in lotteryNumber.SecondBallArray) {
                                if (number2!=number) {
                                    for (NSNumber *number3 in lotteryNumber.ThirdBallArray) {
                                        if (number3!=number2&&number3!=number) {
                                            num++;
                                        }
                                    }
                                }
                            }
                        }
                        if (num == 0) {
                            [JddCommonFunction messageBoxWithMessage:@"请至少选择三个不同号码"];
                            return;
                        }
                    }
                }
            }
            
            [lotteryNumberArray removeAllObjects];
            JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
            [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
            [newNumber.SecondBallArray addObjectsFromArray:lotteryNumber.SecondBallArray];
            [newNumber.ThirdBallArray addObjectsFromArray:lotteryNumber.ThirdBallArray];
            [lotteryNumberArray addObject:newNumber];
            [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                 fromController:self
                                                                     withObject:lotteryNumberArray
                                                                    withObject2:playmetoh];
            
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_GROUP2) {
            if ([lotteryNumber.BallArray count] < 2) {
                [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_2];
                return;
            }
            
            [lotteryNumberArray removeAllObjects];
            JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
            [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
            [lotteryNumberArray addObject:newNumber];
            [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                 fromController:self
                                                                     withObject:lotteryNumberArray
                                                                    withObject2:playmetoh];
            
        }if (selectType == LOTTERY_PLAY_METHOD_11YDJ_GROUP3) {
            if ([lotteryNumber.BallArray count] < 3) {
                [JddCommonFunction messageBoxWithMessage:PICK_NUM_11S5_NOT_CORRECT_3];
                return;
            }
            
            [lotteryNumberArray removeAllObjects];
            JddS5F11Number *newNumber = [[JddS5F11Number alloc] init];
            [newNumber.BallArray addObjectsFromArray:lotteryNumber.BallArray];
            [lotteryNumberArray addObject:newNumber];
            [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_PICK_NUM_11YDJ_LIST
                                                                 fromController:self
                                                                     withObject:lotteryNumberArray
                                                                    withObject2:playmetoh];
            
        }
    }
    
}

- (IBAction)randomSelect1:(id)sender {
    [lotteryNumberArray removeAllObjects];
    
    [lotteryNumber clear];
    for (int i = 0; i < 1; ++i) {
       // [JddCommonFunction generateBallOf11s5Number:lotteryNumber type:type];
        [JddCommonFunction generateBallOf11YDJNumber:lotteryNumber type:selectType];
        [lotteryNumberArray addObject:lotteryNumber];
    }
    float delay = 0;
    if (selectType==6209) {
        for (UIView *subView in self.view.subviews) {
            if ([[subView class] isSubclassOfClass:[UIButton class]] && subView.tag == 11) {
                BOOL shouldSelected = NO;
                if ([lotteryNumber BallHasNumber:[((UIButton*)subView).titleLabel.text intValue]]) {
                    shouldSelected = YES;
                    [JddCommonFunction animationViewWithZoomOutIn:subView delaySecond:(delay+=0.05)];
                }
                [((UIButton*)subView) setSelected:shouldSelected];
            }
            if ([[subView class] isSubclassOfClass:[UIButton class]] && subView.tag == 22) {
                BOOL shouldSelected = NO;
                if ([lotteryNumber Ball2HasNumber:[((UIButton*)subView).titleLabel.text intValue]]) {
                    shouldSelected = YES;
                    [JddCommonFunction animationViewWithZoomOutIn:subView delaySecond:(delay+=0.05)];
                }
                [((UIButton*)subView) setSelected:shouldSelected];
            }
        }
    }else if (selectType==6210) {
        for (UIView *subView in self.view.subviews) {
            if ([[subView class] isSubclassOfClass:[UIButton class]] && subView.tag == 11) {
                BOOL shouldSelected = NO;
                if ([lotteryNumber BallHasNumber:[((UIButton*)subView).titleLabel.text intValue]]) {
                    shouldSelected = YES;
                    [JddCommonFunction animationViewWithZoomOutIn:subView delaySecond:(delay+=0.05)];
                }
                [((UIButton*)subView) setSelected:shouldSelected];
            }
            if ([[subView class] isSubclassOfClass:[UIButton class]] && subView.tag == 22) {
                BOOL shouldSelected = NO;
                if ([lotteryNumber Ball2HasNumber:[((UIButton*)subView).titleLabel.text intValue]]) {
                    shouldSelected = YES;
                    [JddCommonFunction animationViewWithZoomOutIn:subView delaySecond:(delay+=0.05)];
                }
                [((UIButton*)subView) setSelected:shouldSelected];
            }
            if ([[subView class] isSubclassOfClass:[UIButton class]] && subView.tag == 33) {
                BOOL shouldSelected = NO;
                if ([lotteryNumber Ball3HasNumber:[((UIButton*)subView).titleLabel.text intValue]]) {
                    shouldSelected = YES;
                    [JddCommonFunction animationViewWithZoomOutIn:subView delaySecond:(delay+=0.05)];
                }
                [((UIButton*)subView) setSelected:shouldSelected];
            }
        }
    }else if(selectType > 6200){
        for (UIView *subView in self.view.subviews) {
            if ([[subView class] isSubclassOfClass:[UIButton class]] && subView.tag == 11) {
                BOOL shouldSelected = NO;
                if ([lotteryNumber BallHasNumber:[((UIButton*)subView).titleLabel.text intValue]]) {
                    shouldSelected = YES;
                    [JddCommonFunction animationViewWithZoomOutIn:subView delaySecond:(delay+=0.05)];
                }
                [((UIButton*)subView) setSelected:shouldSelected];
            }
        }
    }
    
    [self countMoney];
    
}

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
}

-(void)startQuery{
    if (querystate==YES) {
        querystate = NO;
        [self requestQueryDigitalLotteryIssueOperation];
    }
}

- (void)countDownTimer:(NSTimer*)thisTimer{
    currentTime = [currentTime dateByAddingTimeInterval:1];
    
    NSTimeInterval interval = [endTime timeIntervalSinceDate:currentTime];
    if (interval <= 1) {
        querystate = YES;
        interval = 0;
        [self startQuery];
        return;
        
    } else if(interval>1) {
        NSInteger remainDay = interval / 86400;
        NSInteger remainHour = (interval - 86400 * remainDay) / 3600;
        NSInteger remainMinute = (interval - 86400 * remainDay - remainHour * 3600) / 60;
        NSInteger remainSecond = (interval - 86400 * remainDay - remainHour *3600 - remainMinute * 60);
        remainTimeLabel.text = [NSString stringWithFormat:@"%d分%d秒", remainMinute, remainSecond];
    }
}

- (void)QueryDigitalLotteryIssueOperationResult:(NSData *)result{
    if (result) {
        if ([JddDataParser parseLotteryIssueResult:result lotteryIssue:currentLotteryIssue]){
            issueCodeLabel.text = [NSString stringWithFormat:@"第%@期",currentLotteryIssue.name];
            endTime = [JddCommonFunction dateFromString:currentLotteryIssue.endTime];
            currentTime = [JddCommonFunction dateFromString:currentLotteryIssue.currentTime];
            
            countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1
                                                              target:self
                                                            selector:@selector(countDownTimer:)
                                                            userInfo:nil
                                                             repeats:YES];
        }
    }
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void)listSelect{
//    CGRect rect = [[UIScreen mainScreen] bounds];
//    rect.origin.x = (rect.size.width) / 2.0;
//    rect.origin.y = (rect.size.height) / 2.0;
//    rect.size.width = 251.0;
//    rect.size.height = 300.0;
//    indexList = [JddIndexListView getInstanceView];
//    [indexList setFrame:rect];
//    indexList.type = 0;
//    indexList.delegate = self;
//    [indexList show];
    NoticeViewController *noticeView = [[NoticeViewController alloc] init];
    noticeView.webInfoId = LOTTERY_TYPE_ID_11YDJ;
    [self.navigationController pushViewController:noticeView animated:YES];
}

//-(void)selectorbutton1{
//    
//    [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST
//                                                         fromController:self
//                                                             withObject:[NSNumber numberWithInt:LOTTERY_TYPE_ID_11YDJ]
//                                                            withObject2:nil];
//}
//
//-(void)selectorbutton2{
//    if (![JddCommonFunction isLogin]) {
//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"玩球球"
//                                                        message:@"您还没有登录，请先登录"
//                                                       delegate:self
//                                              cancelButtonTitle:@"确定"
//                                              otherButtonTitles:@"取消", nil]
//        ;
//        [alert show];
//    }else {
//        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_BUY_HISTORY
//                                                             fromController:self
//                                                                 withObject:[NSNumber numberWithInt:LOTTERY_TYPE_ID_11YDJ]
//                                                                withObject2:nil];
//    }
//}
//
//-(void)selectorbutton3{
//    [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_HOW_TO_PLAY_SSQ
//                                                         fromController:self
//                                                             withObject:nil
//                                                            withObject2:nil];
//}
//
//-(void)selectorbutton4{
//    if (![JddCommonFunction isLogin]) {
//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"玩球球"
//                                                        message:@"您还没有登录，请先登录"
//                                                       delegate:self
//                                              cancelButtonTitle:@"确定"
//                                              otherButtonTitles:@"取消", nil]
//        ;
//        [alert show];
//    }else {
//        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_FOLLOW_NUMBER_HISTORY
//                                                             fromController:self
//                                                                 withObject:nil
//                                                                withObject2:nil];
//    }
//}
- (void)loadNavBar
{
    UIButton *right = [UIButton buttonWithType:UIButtonTypeCustom];
    right.frame = CGRectMake(0, 0, 40, 30);
    [right setTitle:@"帮助" forState:UIControlStateNormal];
    right.titleLabel.font = [UIFont systemFontOfSize:15];
    [right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [right addTarget:self action:@selector(listSelect) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:right];
    
}



//- (void)backView
//{
//    [self.navigationController popViewControllerAnimated:YES];
//}


- (void)viewDidLoad
{
    [super viewDidLoad];
    [self loadNavBar];
    label1.hidden = YES;
    label2.hidden = YES;
    label3.hidden = YES;

    for (UIView *subView in self.view.subviews) {
        if ([[subView class] isSubclassOfClass:[UIButton class]]) {
            NSInteger number = [((UIButton*)subView).titleLabel.text intValue];
            int tagnumber = ((UIButton*)subView).tag;
            if (number > 0 && number < 14&&tagnumber==11) {
                [((UIButton*)subView) setBackgroundImage:[UIImage imageNamed:@"jdd_redbollselected"] forState:UIControlStateSelected];
                [((UIButton*)subView) setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            }if (number > 0 && number < 14&&tagnumber==22) {
                [((UIButton*)subView) setBackgroundImage:[UIImage imageNamed:@"jdd_redbollselected"] forState:UIControlStateSelected];
                [((UIButton*)subView) setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            }if (number > 0 && number < 14&&tagnumber==33) {
                [((UIButton*)subView) setBackgroundImage:[UIImage imageNamed:@"jdd_redbollselected"] forState:UIControlStateSelected];
                [((UIButton*)subView) setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            }
        }
    }
    
    
    selectType = LOTTERY_PLAY_METHOD_11YDJ_ANY5;
    _floatLayerIndex = 4;
//  [self.navigationItem setTitle:PAGE_11YDJ_PICK_NUMBER];
    
        UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
        customLab.backgroundColor = [UIColor clearColor];
        [customLab setText:PAGE_11YDJ_PICK_NUMBER];
        customLab.textAlignment = NSTextAlignmentCenter;

        [customLab setTextColor:[UIColor whiteColor]];
        customLab.font = [UIFont systemFontOfSize:19];
        self.navigationItem.titleView = customLab;

    playFormMoneyLabel.text = @"540彩豆";
    playFormIndexLabel.text = @"投注与开奖号码5个相同，即中奖";
    playFormLabel.text = @"任选五";
    [self hiddenButton];
    [self hiddenButton2];
    currentLotteryIssue = [[JddLotteryIssue alloc] init];
    lotteryNumber = [[JddS5F11Number alloc] init];
    lotteryNumberArray = [NSMutableArray array];
    
    [[UIAccelerometer sharedAccelerometer] setDelegate:self];
    [[UIAccelerometer sharedAccelerometer] setUpdateInterval:1.0];
    
    //添加下拉选择
    [self addMenuBtn];
}

-(void)addMenuBtn
{
    
    playFormMoneyLabel.text = @"540彩豆";
    playFormIndexLabel.text = @"投注与开奖号码5个相同，即中奖";
    playFormLabel.text = @"任选五";
    NSString *title = [NSString stringWithFormat:@"%@-任选五",PAGE_11YDJ_PICK_NUMBER];
    
    rv = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-140, 30)];
    rBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rBtn addTarget:self action:@selector(selectPlayMethodButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [rBtn setTitle:title forState:UIControlStateNormal];
    rBtn.titleLabel.font = [UIFont systemFontOfSize: 19.0];
    [rBtn setFrame:CGRectMake(0, 2, 180, 19)];
    rBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    UIImage *rBtnImg = LOADIMAGE(@"navBar_down");
    rImv = [[UIImageView alloc] initWithImage:rBtnImg];
    [self setRightBtnImage:title];
    
    //创建的一个view，加入btn和图片
    [rv addSubview: rBtn];
    [rv addSubview:rImv];
    self.navigationItem.titleView = rv;
    
    //加入手势
    rImv.userInteractionEnabled = YES;
    UITapGestureRecognizer *recognizer=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectPlayMethodButtonClicked)];
    [rImv addGestureRecognizer:recognizer];
}

//计算rImv的坐标
-(void)setRightBtnImage:(NSString *)titleStr
{
    JddSportNumber *btntitle = [[JddSportNumber alloc] init];
    btntitle.titleStr = titleStr;
    CGFloat width = [btntitle customWidth:19 font:19];
    rBtn.center = CGPointMake(90, 15);
    CGRect frame = rBtn.frame;
    frame.origin.x = (rv.width - width - 23) / 2;
    frame.size.width = width;
    rBtn.frame = frame;
    [rImv setFrame:CGRectMake(rBtn.frame.origin.x + width + 3, 9, 20, 12)];
}

//选择彩种
-(void)setRbtnTitle:(NSString *)title
{
    [rBtn setTitle:title forState:UIControlStateNormal];
    [self clearSelect:nil];
    [self setRightBtnImage:title];
}

-(void)destoryView{
    [lotteryNumber clear];
    countlabel.text = @"";
    moneylabel.text = @"";
    playFormMoneyLabel.text = @"13彩豆";
    playFormIndexLabel.text = @"投注与开奖号码第1位相同，即中奖";
    playFormLabel.text = @"任选五";
    selectType = LOTTERY_PLAY_METHOD_11YDJ_ANY5;
    label1.hidden = YES;
    label2.hidden = YES;
    label3.hidden = YES;
    image.image= [UIImage imageNamed:@"jdd_bjwpms.png"];
    [self hiddenButton];
    [self hiddenButton2];
    for (UIView *subView in self.view.subviews) {
        if ([[subView class] isSubclassOfClass:[UIButton class]] ||
            subView.tag == 11||subView.tag == 22 ||subView.tag == 33) {
            [((UIButton*)subView) setSelected:NO];
        }
    }
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"11YDJ"];
    [MobClick event:@"Lottery-11YDJ"];

    [self setRbtnTitle:[NSString stringWithFormat:@"%@-%@",PAGE_11YDJ_PICK_NUMBER,playFormLabel.text]];
    [self requestQueryDigitalLotteryIssueOperation];
    [self randomSelect1:nil];
}

-(void)requestQueryDigitalLotteryIssueOperation
{
    [countDownTimer invalidate];
    JddQueryDigitalLotteryIssueOperation *operation = [[JddQueryDigitalLotteryIssueOperation alloc] init];
    operation.delegate = self;
    NSString *lotterId = [NSString stringWithFormat:@"%d", LOTTERY_TYPE_ID_11YDJ];
    operation.lotteryTypeId = lotterId;
    [[JddGlobalParameter sharedInstance].operationQueue addOperation:operation];
}

- (void)viewWillDisappear:(BOOL)animated{
    [countDownTimer invalidate];
    [MobClick endLogPageView:@"11YDJ"];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark 摇一摇的实现
- (BOOL)canBecomeFirstResponder
{
    return YES;
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{

}

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
    [self randomSelect1:nil];
}

- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    //  NSLog(@"取消");
}


@end
